﻿@model MediaAdmin.Controllers.AssetController.AssetSummary

@{
    ViewBag.Title = "Media asset details";
}

<h2>Media asset details</h2>

<fieldset>
    <legend>AssetSummary</legend>
    <br />
    <div class="display-field">
        Name: @Html.DisplayFor(model => model.Name)
    </div>
    <br />
   <div class="display-field">
       State: @Html.DisplayFor(model => model.State)
    </div>
    <br />
    <div class="display-field">
        Created: @Html.DisplayFor(model => model.Created)
    </div>
    <br />
    <div class="display-field">
        id: @Html.DisplayFor(model => model.Id)
    </div>
    <br />
@foreach (var file in Model.Files)
{            
    <div class="display-field">
        File :  @file.Name of @file.SizeMb Mb
    </div>
}
    <br />

    <h6>Asset locators</h6>
    <hr />
<table>

    @foreach (var locator in Model.Locators){
    <tr>
        <td>
            @locator.Type
        </td>
        <td>
            @locator.AccessPolicyPermissions
        </td>
        <td>
            @locator.AccessPolicyDuration
        </td>
        <td>
            <a href="@locator.Path">locator link</a>
        </td>
        <td>
            @if(locator.Type == "Sas")
            {
                if(locator.AccessPolicyPermissions == "Write")
                {
                    @Html.ActionLink("upload", "Upload", "Locator", new { locatorid = locator.Id, assetid = Model.Id}, null) <strong>|</strong>
                }else
                {
                    @Html.ActionLink("download", "Download", "Locator", new { locatorid = locator.Id, assetid = Model.Id}, null) <strong>|</strong>
                }
            }
            
            @if(locator.Type == "Origin")
            {
                if(Model.Manifest.Contains("m3u8"))
                {
                    @Html.ActionLink("view", "Play", "Locator", new { locatorid = locator.Id, manifest = Model.Manifest }, null) <strong>|</strong>@*
                    @Html.ActionLink("ios-view", "IosPlay", "Locator", new { locatorid = locator.Id, manifest = Model.Manifest }, null) <strong>|</strong>*@
                }
                else
                {
                    @Html.ActionLink("view", "SlvPlay", "Locator", new { locatorid = locator.Id, manifest = Model.Manifest }, null) <strong>|</strong>
                }
            }
            @Html.ActionLink("delete", "Delete", "Locator", new{ locatorid = locator.Id }, null)
        </td>
    </tr>
}

</table>
    <hr />
</fieldset>
<p>
    @Html.ActionLink("Edit", "Edit", new { id=Model.Id }) |
    @Html.ActionLink("Back to List", "Index")
</p>
